package com.newdjk.newdoctor.ui;

import android.content.Intent;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;

import androidx.appcompat.app.AppCompatActivity;

import com.bumptech.glide.Glide;
import com.google.gson.Gson;
import com.newdjk.newdoctor.R;
import com.newdjk.newdoctor.entity.ShowImageEntity;

import butterknife.BindView;
import butterknife.ButterKnife;
import uk.co.senab.photoview.PhotoView;
import uk.co.senab.photoview.PhotoViewAttacher;

public class ShowBigImageActivity extends AppCompatActivity {


    @BindView(R.id.origin_picture)
    PhotoView originPicture;
    private String mPath;
    private String doctorType;
    private String doctorPositionName;
    private String TAG = "ShowBigImageActivity";
    private Gson gson = new Gson();

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        // TODO: add setContentView(...) invocation
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
                WindowManager.LayoutParams.FLAG_FULLSCREEN);
        setContentView(R.layout.show_picture_simple);
        ButterKnife.bind(this);

        Intent intent = getIntent();
        String imgdata = intent.getStringExtra("imgdata");
        if (!TextUtils.isEmpty(imgdata)) {
            ShowImageEntity showImageEntity = gson.fromJson(imgdata, ShowImageEntity.class);
            Glide.with(ShowBigImageActivity.this)
                    .load(showImageEntity.getUrl().get(0))
                    //.diskCacheStrategy(DiskCacheStrategy.ALL)
                    .into(originPicture);
        }
        originPicture.setOnPhotoTapListener(new PhotoViewAttacher.OnPhotoTapListener() {
                                                @Override
                                                public void onPhotoTap(View view, float x, float y) {
                                                    finish();
                                                }

                                                @Override
                                                public void onOutsidePhotoTap() {

                                                }
                                            }
        );
    }
}
